﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SortGUI
{
    public abstract class SortBase
    {
        public int count = 0;
        public int[] lastSwappedIndices = new int[2];
        public int lastSortedIndex = -1;
        public bool isSorting = false;
        public bool isInitialize = false;
        public bool swapped = false;
        public UpdateUiDelegate updateUiCallback = null;
        public UpdataColor updataColor = null;
        //定义一个委托
        public delegate void UpdateUiDelegate(int count, int[] lastSwappedIndices, int lastSortedIndex, bool swapped);
        public delegate void UpdataColor(bool isInitialize);
        public abstract void Sort(int[] alNum);
        public virtual void Initialize() { } // consider paraters 初始化一些变量
        public virtual void SortNextStep() { }//排序完成后更新页面,传递参数
        public virtual void Complete() { }
        public void Swap(ref int x, ref int y)
        {
            int temp = x;
            x = y;
            y = temp;
        }
    }
}

